<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <h3>我是首页</h3>
    {{message}}
    <hr/>
    <button @click="loadMethod('a')">a方法</button>
    <button @click="loadMethod('b')">b方法</button>
    <button @click="loadMethod('c')">c方法</button>
</div>
</body>
</html>
<script src="js/vue.min.js"></script>
<script src="js/axios.min.js"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                message: ''
            }
        },
        methods: {
            loadMethod(methodName) {
                let _this = this;
                let token = window.localStorage.getItem('token')
                console.log(token)
                axios.get('user/' + methodName, {
                    headers: {
                        token: token
                    }
                }).then((response) => {
                    if (response.data.success) {
                        console.log(response.data)
                        _this.message = response.data.data
                    } else {
                        location.href = 'login.html'
                    }
                })
            }
        }
    })
</script>